package com.caseeye.controller;

import javax.servlet.http.HttpServletRequest;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

import com.caseeye.service.CaseService;
import com.caseeye.command.LoginInfo;

@Component
@RequestMapping("/case")
public class CaseController {

	@Autowired(required = true)
	private CaseService caseService;

	public void setCaseService(CaseService caseService) {
		this.caseService = caseService;
	}

	@RequestMapping(value = "/{projectId}", method = RequestMethod.GET)
	public String getCaseList(@PathVariable Integer projectId,
			HttpServletRequest request, Model model) {
		LoginInfo loginInfo = (LoginInfo) request.getSession().getAttribute("loginInfo");
		System.out.println(loginInfo.getLoginId());
		model.addAttribute("projectId", projectId);
		model.addAttribute("caseList", caseService.getCaseList(projectId));
		return "jsonview";
	}
}
